# $Id$
# Maintainer: Jan de Groot <jgc@archlinux.org>

pkgbase=pygobject2
pkgname=(python-gobject2 python2-gobject2 pygobject2-devel)
pkgver=2.28.6
pkgrel=13
arch=(i686 x86_64)
url="http://www.pygtk.org/"
license=(LGPL)
makedepends=(python python2 git)

# pygobject-2-28 branch: https://git.gnome.org/browse/pygobject/log/?h=pygobject-2-28
source=('git://git.gnome.org/pygobject#commit=9456ba7')
sha256sums=('SKIP')

prepare() {
  cd pygobject
  autoreconf -fi

  cp -a . ../python2-build

  find -O3 ../python2-build \
    \( -name '*.py' -o -name '*.py.in' \) \
    -exec sed -i '1s|python$|&2|' {} +
}

build() {
  cd python2-build
  ./configure --prefix=/usr --disable-introspection \
    PYTHON=/usr/bin/python2
  make

  cd ../pygobject
  ./configure --prefix=/usr --disable-introspection
  make
}

package_python-gobject2() {
  pkgdesc="Python 3 bindings for GObject2"
  depends=(glib2 pygobject2-devel python)
  replaces=(py3gobject)
  provides=("py3gobject=$pkgver")

  cd pygobject
  make DESTDIR="$pkgdir" install

  # Delete devel stuff
  rm -r "$pkgdir"/usr/{include,lib/pkgconfig,share/{gtk-doc,pygobject/xsl}}
}

package_python2-gobject2() {
  pkgdesc="Python 2 bindings for GObject2"
  depends=(glib2 pygobject2-devel python2)
  replaces=(pygobject)
  provides=("pygobject=$pkgver")

  cd python2-build
  make DESTDIR="$pkgdir" install

  rm -r "$pkgdir"/usr/share/gtk-doc

  # Split devel stuff
  cd ..
  mkdir -p devel/usr/{lib,share/pygobject}
  mv {"$pkgdir",devel}/usr/include
  mv {"$pkgdir",devel}/usr/lib/pkgconfig
  mv {"$pkgdir",devel}/usr/share/pygobject/xsl
}

package_pygobject2-devel() {
  pkgdesc="Development files for the pygobject bindings"
  mv devel/* "$pkgdir"
}
